package edu.mse.camel.client.whiteboard.diagram.part;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

import edu.mse.camel.client.whiteboard.diagram.providers.WhiteboardElementTypes;

/**
 * @generated
 */
public class WhiteboardPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createShapes1Group());
		paletteRoot.add(createConnectors2Group());
	}

	/**
	 * Creates "Shapes" palette tool group
	 * @generated
	 */
	private PaletteContainer createShapes1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Shapes1Group_title);
		paletteContainer.setDescription(Messages.Shapes1Group_desc);
		paletteContainer.add(createEllipse1CreationTool());
		paletteContainer.add(createRectangle2CreationTool());
		paletteContainer.add(createRoundedRectangle3CreationTool());
		paletteContainer.add(createDiamond4CreationTool());
		paletteContainer.add(createCylinder5CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Connectors" palette tool group
	 * @generated
	 */
	private PaletteContainer createConnectors2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.Connectors2Group_title);
		paletteContainer.add(createSolidConn1CreationTool());
		paletteContainer.add(createSolidArrowConn2CreationTool());
		paletteContainer.add(createSolidDoubleArrowConn3CreationTool());
		paletteContainer.add(createDashedConn4CreationTool());
		paletteContainer.add(createDashedArrowConn5CreationTool());
		paletteContainer.add(createDashedDoubleArrowConn6CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEllipse1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.Ellipse_1002);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Ellipse1CreationTool_title,
				Messages.Ellipse1CreationTool_desc, types);
		entry.setSmallIcon(WhiteboardElementTypes
				.getImageDescriptor(WhiteboardElementTypes.Ellipse_1002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRectangle2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.Rectangle_1003);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Rectangle2CreationTool_title,
				Messages.Rectangle2CreationTool_desc, types);
		entry.setSmallIcon(WhiteboardElementTypes
				.getImageDescriptor(WhiteboardElementTypes.Rectangle_1003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRoundedRectangle3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.RoundedRectangle_1005);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.RoundedRectangle3CreationTool_title,
				Messages.RoundedRectangle3CreationTool_desc, types);
		entry
				.setSmallIcon(WhiteboardElementTypes
						.getImageDescriptor(WhiteboardElementTypes.RoundedRectangle_1005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDiamond4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.Diamond_1004);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Diamond4CreationTool_title,
				Messages.Diamond4CreationTool_desc, types);
		entry.setSmallIcon(WhiteboardElementTypes
				.getImageDescriptor(WhiteboardElementTypes.Diamond_1004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createCylinder5CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.Cylinder_1001);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Cylinder5CreationTool_title,
				Messages.Cylinder5CreationTool_desc, types);
		entry.setSmallIcon(WhiteboardElementTypes
				.getImageDescriptor(WhiteboardElementTypes.Cylinder_1001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSolidConn1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.SolidConn_3001);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.SolidConn1CreationTool_title,
				Messages.SolidConn1CreationTool_desc, types);
		entry.setSmallIcon(WhiteboardElementTypes
				.getImageDescriptor(WhiteboardElementTypes.SolidConn_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSolidArrowConn2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.SolidArrowConn_3002);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.SolidArrowConn2CreationTool_title,
				Messages.SolidArrowConn2CreationTool_desc, types);
		entry
				.setSmallIcon(WhiteboardElementTypes
						.getImageDescriptor(WhiteboardElementTypes.SolidArrowConn_3002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSolidDoubleArrowConn3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.SolidDoubleArrowConn_3003);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.SolidDoubleArrowConn3CreationTool_title,
				Messages.SolidDoubleArrowConn3CreationTool_desc, types);
		entry
				.setSmallIcon(WhiteboardElementTypes
						.getImageDescriptor(WhiteboardElementTypes.SolidDoubleArrowConn_3003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDashedConn4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.DashConn_3004);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.DashedConn4CreationTool_title,
				Messages.DashedConn4CreationTool_desc, types);
		entry.setSmallIcon(WhiteboardElementTypes
				.getImageDescriptor(WhiteboardElementTypes.DashConn_3004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDashedArrowConn5CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.DashArrowConn_3005);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.DashedArrowConn5CreationTool_title,
				Messages.DashedArrowConn5CreationTool_desc, types);
		entry.setSmallIcon(WhiteboardElementTypes
				.getImageDescriptor(WhiteboardElementTypes.DashArrowConn_3005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDashedDoubleArrowConn6CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(WhiteboardElementTypes.DashDoubleArrowConn_3006);
		LinkToolEntry entry = new LinkToolEntry(
				Messages.DashedDoubleArrowConn6CreationTool_title,
				Messages.DashedDoubleArrowConn6CreationTool_desc, types);
		entry
				.setSmallIcon(WhiteboardElementTypes
						.getImageDescriptor(WhiteboardElementTypes.DashDoubleArrowConn_3006));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
